/**
 * 渠道设置
 */
import request from '@/utils/request';
// import { stringify } from 'qs';

// -------------------邮箱设置-----------------

/**
 * 搜索个人员工
 * @param {*} params
 */
export function searchEmployee({ name, currentOrgCode }) {
    return request(
        `/api/uc/approve/v1/employee/detail/info/not/quited/list?organizationCode=${currentOrgCode}&name=${name}`
    );
}
/**
 * 检查邮箱
 * @param {*} params
 */
export function checkEmail(params) {
    return request('/api/mail/v1/user/bind/checkMailBind', {
        method: 'POST',
        data: params
    });
}
/**
 * 保存邮箱
 * @param {*} params
 */
export function saveEmail(params) {
    return request('/api/recruitment/v1/email_employees/actions/email_employee', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取邮箱设置列表
 * @param {*} params
 */
export function getEmailListPage(params) {
    return request('/api/recruitment/v1/email_employees/actions/emialemployeepage', {
        method: 'POST',
        data: params
    });
}
/**
 * 删除邮箱
 * @param {*} params
 */
export function deleteEmail(id) {
    return request(`/api/recruitment/v1/email_employees/actions/del_email_employee/${id}`, {
        method: 'DELETE'
    });
}

// -------------------渠道设置-----------------

/**
 * 所有渠道-不隔离-不包含人才库
 */
export async function getChannelTreeWithoutTalent(params) {
    return request('/api/recruitment/v1/channel_settings/channel_group_list', {
        method: 'POST',
        data: params
    });
}

/**
 * 所有渠道-不隔离-不包含人才库
 */
export async function getChannelListWithoutTalent(params) {
    return request('/api/recruitment/v1/channel_settings/channel_select_list', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取对外岗位信息字段列表
 * @param {*} params
 */
export function getChannelColumns() {
    return request('/api/recruitment/v1/recruit_outwards/outwardcolumns', {
        method: 'GET'
    });
}

/**
 * 获取渠道列表
 * @param {*} params
 */
export function getChannelList(params) {
    return request('/api/recruitment/v1/channel_settings/channellist', {
        method: 'POST',
        data: params
    });
}

/**
 * 新增渠道（猎头）
 * @param {*} params
 */
export function addHuntingChannel(params) {
    return request('/api/recruitment/v1/channel_settings/actions/save_headhunting_channel', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新渠道（猎头）
 * @param {*} params
 */
export function updateHuntingChannel(params) {
    return request(`/api/recruitment/v1/channel_settings/actions/update_headhunting_channel/${params?.channelId}`, {
        method: 'PUT',
        data: params
    });
}

/**
 * 新增渠道（自定义）
 * @param {*} params
 */
export function addCustomChannel(params) {
    return request('/api/recruitment/v1/channel_settings/custom_channels', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新渠道（自定义）
 * @param {*} params
 */
export function updateCustomChannel(params) {
    return request(`/api/recruitment/v1/channel_settings/custom_channels/${params?.channelId}`, {
        method: 'POST',
        data: params
    });
}

/**
 * 删除渠道（自定义）
 * @param {*} params
 */
export function deleteCustomChannel(channelId) {
    return request(`/api/recruitment/v1/channel_settings/custom_channels/${channelId}`, {
        method: 'DELETE'
    });
}

/**
 * 更新渠道（招聘网站）
 * @param {*} params
 */
export function updateExternalChannel(params) {
    return request(`/api/recruitment/v1/channel_settings/actions/update_external_channel/${params?.channelId}`, {
        method: 'PUT',
        data: params
    });
}

/**
 * 删除渠道（猎头）
 * @param {*} params
 */
export function deleteHuntingChannel(channelId) {
    return request(`/api/recruitment/v1/channel_settings/actions/del_channel/${channelId}`, {
        method: 'DELETE'
    });
}

/**
 * 保存设置
 * @param {*} params
 */
export function saveSet(params) {
    return request(`/api/recruitment/v1/channel_settings/${params?.id}/actions/change_channel_status`, {
        method: 'POST',
        data: params
    });
}

/**
 * 获取设置详情
 * @param {*} params
 */
export function getSetDetail(params) {
    return request(`/api/recruitment/v1/channel_settings/channel/detail/${params?.id}`, {
        method: 'GET'
    });
}

/**
 * 获取邮箱列表
 * @param {*} params
 */
export function getEmailList(params) {
    return request('/api/recruitment/v1/email_employees/actions/emialemployeelist', {
        method: 'POST',
        data: params
    });
}

/**
 * 保存渠道账号
 * @param {*} params
 */
export function saveAddAccount(params) {
    return request(`/api/recruitment/v1/channel_settings/${params?.channelCode}/channel_accounts`, {
        method: 'POST',
        data: params
    });
}

/**
 * 更新渠道账号
 * @param {*} params
 */
export function saveEditAccount(params) {
    return request(`/api/recruitment/v1/channel_settings/actions/channel_accounts/${params?.accountId}`, {
        method: 'PUT',
        data: params
    });
}

/**
 * 获取渠道账号详情
 * @param {*} params
 */
export function getChannelDetail(id) {
    return request(`/api/recruitment/v1/channel_settings/channel_accounts/detail/${id}`, {
        method: 'GET'
    });
}

/**
 * 删除渠道账号
 * @param {*} params
 */
export function deleteAccount(id) {
    return request(`/api/recruitment/v1/channel_settings/actions/del_channel_accounts/${id}`, {
        method: 'DELETE'
    });
}

// -------------------邮件模板设置-----------------

/**
 * 获取邮件模板列表
 * @param {*} params
 */
export function getEmailTemplateList(params) {
    return request('/api/recruitment/v1/channel_templates/channeltemplatepage', {
        method: 'POST',
        data: params
    });
}

/**
 * 新增邮件模板
 * @param {*} params
 */
export function addEmailTemplate(params) {
    return request('/api/recruitment/v1/channel_templates/save_channel_templates', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新邮件模板
 * @param {*} params
 */
export function updateEmailTemplate(params) {
    return request(`/api/recruitment/v1/channel_templates/actions/update_channel_templates/${params.id}`, {
        method: 'PUT',
        data: params
    });
}

/**
 * 删除邮件模板
 * @param {*} params
 */
export function deleteEmailTemplate(id) {
    return request(`/api/recruitment/v1/channel_templates/actions/del_channel_templates/${id}`, {
        method: 'DELETE'
    });
}

/**
 * 获取邮件模板详情
 * @param {*} params
 */
export function getEmailTemplate(id) {
    return request(`/api/recruitment/v1/channel_templates/channeltemplate/detail/${id}`, {
        method: 'GET'
    });
}

/**
 * 获取邮件模板选择列表
 * @param {*} params
 */
export function getEmailTemplateListSimple(params) {
    return request('/api/recruitment/v1/channel_templates/channeltemplatevaluelist', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取邮件模板-操作记录
 * @param {*} params
 */
export function getEmailTemplateOperateList(params) {
    return request('/api/recruitment/v1/channel_settings/template_operate_records/actions/search', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取邮件模板-操作记录详情
 * @id {*} id
 */
export function getEmailTemplateOperateDetail(id) {
    return request(`/api/recruitment/v1/channel_settings/template_operate_records/${id}`, {
        method: 'GET'
    });
}

// -------------------字段设置-----------------

/**
 * 获取字段配置列表
 */
export function getFieldSetList() {
    return request('/api/recruitment/v1/channel_settings/channel_columns/position_categories', {
        method: 'GET'
    });
}

/**
 * 获取职位类别树形信息
 */
export function getCategoryTree(channelCode) {
    return request(`/api/recruitment/v1/channel_settings/channel_columns/${channelCode}/position_category_trees`, {
        method: 'GET'
    });
}

/**
 * 获取职位关键字列表
 * @param {*} params
 */
export function getPositionKeywords(params) {
    return request('/api/recruitment/v1/channel_settings/channel_columns/position_keywords', {
        method: 'POST',
        data: params
    });
}

/**
 * 新增字段配置
 * @param {*} params
 */
export function addFieldSet(params) {
    return request('/api/recruitment/v1/channel_settings/channel_columns/actions/save_position_category_and_skill', {
        method: 'POST',
        data: params
    });
}

/**
 * 删除字段配置
 * @param {*} params
 */
export function deleteFieldSet(configId) {
    return request(`/api/recruitment/v1/channel_settings/channel_columns/delete/${configId}`, {
        method: 'POST'
    });
}

/**
 * 获取配置记录列表
 * @param {*} params
 */
export function getFieldSetRecord(params) {
    return request('/api/recruitment/v1/channel_settings/channel_columns/column_config_records', {
        method: 'POST',
        data: params
    });
}

// -------------------面试设置-----------------
/**
 * 获取面试轮次列表
 */
export function getInterviewRoundList() {
    return request('/api/recruitment/v1/interview/round/list', {
        method: 'POST'
    });
}

/**
 * 新增面试轮次
 * @param {*} params
 */
export function addInterviewRound(params) {
    return request('/api/recruitment/v1/interview/round/actions/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新面试轮次
 * @param {*} params
 */
export function updateInterviewRound(params) {
    return request('/api/recruitment/v1/interview/round/actions/update', {
        method: 'PUT',
        data: params
    });
}

/**
 * 删除面试轮次
 * @param {*} params
 */
export function deleteInterviewRound(id) {
    return request(`/api/recruitment/v1/interview/round/actions/delete/${id}`, {
        method: 'DELETE'
    });
}

/**
 * 获取能力评估表列表
 */
export function getEvaluationList() {
    return request('/api/recruitment/v1/settings/eval_form/list', {
        method: 'GET'
    });
}

/**
 * 获取能力评估表
 */
export function getEvaluation(id) {
    return request(`/api/recruitment/v1/settings/eval_form/detail/${id}`, {
        method: 'GET'
    });
}

/**
 * 新增能力评估表
 * @param {*} params
 */
export function addEvaluation(params) {
    return request('/api/recruitment/v1/settings/eval_form/actions/save_eval_form', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新能力评估表
 * @param {*} params
 */
export function updateEvaluation(params) {
    return request('/api/recruitment/v1/settings/eval_form/actions/update_eval_form', {
        method: 'PUT',
        data: params
    });
}

/**
 * 删除能力评估表
 * @param {*} params
 */
export function deleteEvaluation(id) {
    return request(`/api/recruitment/v1/settings/eval_form/actions/delete_eval_form/${id}`, {
        method: 'DELETE'
    });
}

/**
 * 获取声明设置列表
 */
export function getDeclareSetList() {
    return request('/api/recruitment/v1/statement/setting/list', {
        method: 'POST'
    });
}

/**
 * 新增声明设置
 * @param {*} params
 */
export function addDeclareSet(params) {
    return request('/api/recruitment/v1/statement/setting/actions/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新声明设置
 * @param {*} params
 */
export function updateDeclareSet(params) {
    return request('/api/recruitment/v1/statement/setting/actions/update', {
        method: 'PUT',
        data: params
    });
}

/**
 * 删除声明设置
 * @param {*} params
 */
export function deleteDeclareSet(id) {
    return request(`/api/recruitment/v1/statement/setting/actions/delete/${id}`, {
        method: 'DELETE'
    });
}

// -------------------通知模板-----------------
/**
 * 获取通知模板分页列表
 */
export function getNoticeTemplateList(params) {
    return request('/api/recruitment/v1/templates/list', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取通知模板默认填充内容
 */
export function getNoticeTemplateDefaultContent(params) {
    return request('/api/recruitment/v1/templates/list', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取通知模板
 */
export function getNoticeTemplate(id) {
    return request(`/api/recruitment/v1/templates/${id}/actions/read_template`, {
        method: 'GET'
    });
}

/**
 * 获取通知/信息模板预览
 */
export function getNoticeTemplatePreview(params) {
    return request('/api/recruitment/v1/templates/actions/preview_template', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取录用通知模板已选择的机构
 */
export function getUsedOrgList(type = 'offer_notification') {
    return request(`/api/recruitment/v1/templates/filter_organization/${type}`, {
        method: 'GET'
    });
}

/**
 * 新增通知模板
 * @param {*} params
 */
export function addNoticeTemplate(params) {
    return request('/api/recruitment/v1/templates/actions/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 更新通知模板
 * @param {*} params
 */
export function updateNoticeTemplate(params) {
    return request('/api/recruitment/v1/templates/actions/update', {
        method: 'PUT',
        data: params
    });
}

/**
 * 删除通知模板
 * @param {*} params
 */
export function deleteNoticeTemplate(id) {
    return request(`/api/recruitment/v1/templates/${id}/actions/delete_template`, {
        method: 'DELETE'
    });
}

/**
 * 获取招聘设置系统参数
 */
export function getRecruitParam(code) {
    return request(`/api/recruitment/v1/system/param/actions/get/${code}`, {
        method: 'GET'
    });
}

/**
 * 批量获取招聘设置系统参数
 * @param {*} params
 */
export function getRecruitParamList(paramCode) {
    return request('/api/recruitment/v1/system/param/actions/codes', {
        method: 'POST',
        data: { paramCode }
    });
}

/**
 * 更新招聘设置系统参数
 * @param {*} params
 */
export function updateRecruitParam(params) {
    return request('/api/recruitment/v1/system/param/actions/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取集团名称（用于面试签到标题）
 */
export function getFirstOrgInfo() {
    return request('/api/uc/org/v1/getRootOrgList', {
        method: 'GET'
    });
}

// 标签 =================================
/**
 * 获取标签字段树形
 */
export function queryTagsFieldList() {
    return request('/api/recruitment/v1/tags/field/list', {
        method: 'GET'
    });
}

/**
 * 获取所有标签
 */
export function queryTagList() {
    return request('/api/recruitment/v1/tags/list', {
        method: 'GET'
    });
}

/**
 * 获取标签详情
 */
export function getTagDetail(id) {
    return request(`/api/recruitment/v1/tags/detail/${id}`, {
        method: 'GET'
    });
}
/**
 * 新增标签
 */
export async function addTag(data) {
    return request('/api/recruitment/v1/tags/save', {
        method: 'POST',
        data
    });
}

/**
 * 修改标签
 */
export async function updateTag(data) {
    return request('/api/recruitment/v1/tags/update', {
        method: 'POST',
        data
    });
}

/**
 * 删除标签
 */
export async function delTag(id) {
    return request(`/api/recruitment/v1/tags/${id}/actions/delete_tag`, {
        method: 'PUT'
    });
}

/**
 * 招聘行政机构邮箱列表
 */
export async function getRecruitEmailCompanyList(params) {
    return request('/api/recruitment/v1/recruit_email_company_configs/list', {
        method: 'POST',
        data: params
    });
}

/**
 * 招聘行政机构删除邮箱设置
 */
export async function delRecruitEmailCompany(id) {
    return request(`/api/recruitment/v1/recruit_email_company_configs/actions/delete/${id}`, {
        method: 'DELETE'
    });
}

/**
 * 招聘行政机构保存邮箱
 */
export async function saveRecruitEmailCompany(params) {
    return request('/api/recruitment/v1/recruit_email_company_configs/actions/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 招聘行政机构查询邮箱设置
 */
export async function getRecruitEmailCompanyById(id) {
    return request(`/api/recruitment/v1/recruit_email_company_configs/get/${id}`, {
        method: 'GET'
    });
}

/**
 * 邮箱账号密码验证
 */
export async function checkEmailAccount(params) {
    return request('/api/mail/v1/check/account', {
        method: 'POST',
        data: params
    });
}
